﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;

    public class GenericIconPopup extends GenericPopup {

        protected static const MAX_ICON_SIZE:int = 50;

        protected var m_icon:Object;
        protected var m_iconLoader:Loader;

        public function GenericIconPopup(_arg1:String, _arg2:int=1, _arg3:Function=null, _arg4:Object=null){
            m_dialogAsset = "assets/dialogs/TI_GenericIconPopUp.swf";
            this.m_icon = _arg4;
            super(_arg1, _arg2, _arg3, m_dialogAsset);
        }
        override protected function onLoadComplete():void{
            m_window = (m_loader.content as MovieClip);
            m_window.callOutBox_mc.callOut_tf.text = m_message;
            m_window.callOutBox_mc.okay_bt.visible = false;
            if ((this.m_icon is String)){
                this.m_iconLoader = LoadingManager.load((this.m_icon as String), this.onIconLoaded);
            } else {
                if ((this.m_icon is DisplayObject)){
                    this.handleContent((this.m_icon as DisplayObject));
                };
            };
            m_window.callOutBox_mc.close_bt.addEventListener(MouseEvent.CLICK, onCancel);
            setupButtons(m_window.callOutBox_mc.share_bt, m_window.callOutBox_mc.cancel_bt);
            addChild(m_window);
        }
        protected function onIconLoaded(_arg1:Event):void{
            var _local2:DisplayObject = this.m_iconLoader.content;
            this.handleContent(_local2);
        }
        protected function handleContent(_arg1:DisplayObject):void{
            var _local2:MovieClip;
            _local2 = m_window.callOutBox_mc.icon_mc;
            _local2.scaleX = (_local2.scaleY = 1);
            while (_local2.numChildren) {
                _local2.removeChildAt(0);
            };
            _arg1.scaleX = (_arg1.scaleY = Math.min(1, (_arg1.width / MAX_ICON_SIZE), (_arg1.height / MAX_ICON_SIZE)));
            _arg1.x = (-(_arg1.width) / 2);
            _arg1.y = (-(_arg1.height) / 2);
            _local2.addChild(_arg1);
        }

    }
}//package Display 
